package cn.eaay.stock.service.impl;

import cn.eaay.stock.dto.StockOuterDto;
import cn.eaay.stock.service.StockOuterService;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@Service
public class StockOuterServiceImpl implements StockOuterService {

    @Resource
    private RestTemplate restTemplate;

    @Override
    public void pullOuterInfo() {
        String url = "http://api.k780.com/?app=finance.globalindex&inxids=1010&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json";
        StockOuterDto data = restTemplate.getForObject(url, StockOuterDto.class);
        System.out.println(data);
        // Gson gson = new Gson();
        // String dataStr = gson.toJson(data);
        // StockOuterDto result = gson.fromJson(dataStr, new TypeToken<StockOuterDto>() {
        // }.getType());
        // System.out.println(result);
    }
}
